using Microsoft.Phone.Controls.Properties;
using System;
using System.Globalization;
using System.Windows.Data;
namespace Microsoft.Phone.Controls
{
	public class ListViewDateTimeConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (!(value is DateTime))
			{
				throw new ArgumentException(Resources.InvalidDateTimeArgument);
			}
			DateTime dateTime = (DateTime)value;
			DateTime now = DateTime.get_Now();
			if (DateTimeFormatHelper.IsFutureDateTime(now, dateTime))
			{
				throw new NotSupportedException(Resources.NonSupportedDateTime);
			}
			string result;
			if (DateTimeFormatHelper.IsAnOlderWeek(now, dateTime))
			{
				result = DateTimeFormatHelper.GetMonthAndDay(dateTime);
			}
			else
			{
				if (DateTimeFormatHelper.IsPastDayOfWeek(now, dateTime))
				{
					result = DateTimeFormatHelper.GetAbbreviatedDay(dateTime);
				}
				else
				{
					result = DateTimeFormatHelper.GetSuperShortTime(dateTime);
				}
			}
			return result;
		}
		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			throw new NotImplementedException();
		}
	}
}
